package cn.tedu.service.impl;

import cn.tedu.constant.WxConstant;
import cn.tedu.service.IMessageHandler;
import me.chanjar.weixin.common.api.WxConsts;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author Kiven
 */
@Service(WxConsts.XmlMsgType.EVENT)
public class EventMessageHandler implements IMessageHandler {
    @Override
    public String handler(Map<String, Object> map) {
        String msgType = (String)map.get(WxConstant.EVENT_TYPE);
        if(WxConsts.EventType.SUBSCRIBE.equals(msgType)){
            // 可以存数据库
            System.out.println("有人关注: "+map);
        }else if(WxConsts.EventType.UNSUBSCRIBE.equals(msgType)){
            // 按照微信要求取关之后应该删除数据库用户信息
            System.out.println("有人取消关注: "+map);
        }
        return "";
    }
}
